import Combine

check("Empty") {
    Empty<Int, SampleError>()
}

check("Fail") {
    Fail<Int, SampleError>(error: .sampleError)
}

check("Just") {
    Just("Hello SwiftUI")
}

check("Sequence") {
    Publishers.Sequence<[Int], Never>(sequence: [Int](1...5))
}

check("Sequence") {
    Publishers.Sequence<ClosedRange<Int>, Never>(sequence: (1...5))
}

check("Array") {
    [Int](1...5).publisher
}

do {
    let stringSubject = PassthroughSubject<String, Never>()
    let intSubject = PassthroughSubject<Int, Never>()
    check("CombineLatest") {
        Publishers.CombineLatest(intSubject, stringSubject)
    }
    
    stringSubject.send("a")
    intSubject.send(1)
    intSubject.send(2)
    intSubject.send(3)
    stringSubject.send("b")
    stringSubject.send("c")
}

check("Zip") {
    Publishers.Zip(["a", "b"].publisher, [Int](1...5).publisher)
}

do {
    let stringSubject = PassthroughSubject<String, Never>()
    let intSubject = PassthroughSubject<Int, Never>()
    check("Merge") {
        Publishers.Merge(intSubject.map { String($0) }, stringSubject)
    }
    intSubject.send(1)
    stringSubject.send("A")
    intSubject.send(2)
    intSubject.send(3)
    stringSubject.send("B")
    stringSubject.send("C")
}

